//
//  RootViewController.m
//  ClassManager
//
//  Created by ihope99 on 2017/8/2.
//  Copyright © 2017年 GZX. All rights reserved.
//

#import "RootViewController.h"
#import "TheCountdownViewController.h"
#import "BaseSearchViewController.h"
#import "ALLButtonViewController.h"
#import "XXViewController.h"
#import "PageScollViewController.h"
#import "EditArrayViewController.h"
#import "SeeBigImageViewController.h"
#import "GDeviceViewController.h"
#import "SetIconViewController.h"
#import "OpenSetURL.h"
#import "BaseAFManager.h"
#import "GetDateManager.h"
#import "AutomaticViewController.h"
#import "AppleTouchViewController.h"
#import "TextViewController.h"
#import "KVCViewController.h"
#import "ImageSelectViewController.h"


@interface RootViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong)UITableView *mTableView;
@property (nonatomic,strong)NSMutableArray *mArray;

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:self.mTableView];

    self.mArray = [NSMutableArray array];
    
    [self.mArray addObject:@"倒计时<倒计时>"];
    [self.mArray addObject:@"搜索框<搜索框>"];
    [self.mArray addObject:@"连续添加多个button导航效果<ALLButtonView>"];
    [self.mArray addObject:@"视频播放<视频播放>"];
    [self.mArray addObject:@"轮播图<轮播图>"];
    [self.mArray addObject:@"数组的处理<简单的获取数组中最大值最小值>"];
    [self.mArray addObject:@"查看大图<查看大图>"];
    [self.mArray addObject:@"声音和震动<声音和震动>"];
    [self.mArray addObject:@"一键设置ICON<一键设置ICON>"];
    [self.mArray addObject:@"跳转设置页面"];
    [self.mArray addObject:@"测试接口"];
    [self.mArray addObject:@"九宫格自动适配"];
    [self.mArray addObject:@"指纹识别"];
    [self.mArray addObject:@"输入文本"];
    [self.mArray addObject:@"KVC && KVO"];
    [self.mArray addObject:@"图片选择器<ImageSelectViewController>"];
    
    [self.mTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        if (@available(ios 11.0,*)) make.edges.mas_equalTo(self.view.safeAreaInsets);
        else make.edges.mas_equalTo(self.view);
    }];
}

-(UITableView *)mTableView{
    if (!_mTableView) {
        _mTableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
//        _mTableView.autoresizingMask = UIViewAutoresizingFlexibleFullFit;
        _mTableView.delegate = self;
        _mTableView.dataSource = self;
        _mTableView.estimatedRowHeight = 50;
        _mTableView.rowHeight = UITableViewAutomaticDimension;
//        _mTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _mTableView;
}

#pragma mark ---- UITableViewDelegate&&UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.mArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier = @"identifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.textLabel.font = KTEXTFONT(13);
    cell.textLabel.text = self.mArray [indexPath.row];
    return cell;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [[UIView alloc]initWithFrame:CGRectMake(0, 0,kScreenWidth, 0.1)];
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [[UIView alloc]initWithFrame:CGRectMake(0, 0,kScreenWidth, 0.1)];
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.1;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 0) {
        TheCountdownViewController *ctrl = [[TheCountdownViewController alloc]init];
        //    ctrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:ctrl animated:YES];
    }
    else if (indexPath.row == 1){
        BaseSearchViewController *ctrl = [[BaseSearchViewController alloc]init];
        ctrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:ctrl animated:YES];
    }
    else if (indexPath.row == 2){
        ALLButtonViewController *ctrl = [[ALLButtonViewController alloc]init];
        ctrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:ctrl animated:YES];
    }
    else if (indexPath.row == 3){
        XXViewController *ctrl = [[XXViewController alloc]init];
        ctrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:ctrl animated:YES];
    }
    else if (indexPath.row == 4){
        PageScollViewController *ctrl = [[PageScollViewController alloc]init];
        ctrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:ctrl animated:YES];
    }
    else if (indexPath.row == 5){
        EditArrayViewController *ctrl = [[EditArrayViewController alloc]init];
        ctrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:ctrl animated:YES];
    }
    else if (indexPath.row == 6){
        SeeBigImageViewController *ctrl = [[SeeBigImageViewController alloc]init];
        ctrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:ctrl animated:YES];
    }
    else if (indexPath.row == 7){
        GDeviceViewController *ctrl = [[GDeviceViewController alloc]init];
        ctrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:ctrl animated:YES];
    }
    else if (indexPath.row == 8){
        SetIconViewController *ctrl = [[SetIconViewController alloc]init];
        ctrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:ctrl animated:YES];
    }
    else if (indexPath.row == 9){
        [OpenSetURL OpenSetUrlWithURLString:@"App-Prefs:root=WIFI"];
    }
    else if (indexPath.row == 10){
        [MTAlert showAlertWithTitle:nil message:@"哈哈哈哈" cancel:@"取消" ok:@"确定" clickBlock:^(NSInteger tag) {

        }];
    }
    else if (indexPath.row == 11){
        AutomaticViewController *ctrl = [[AutomaticViewController alloc]init];
         ctrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:ctrl animated:YES];
    }
    else if (indexPath.row == 12){
        AppleTouchViewController *ctrl = [[AppleTouchViewController alloc]init];
        ctrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:ctrl animated:YES];
    }
    else if (indexPath.row == 13){
        TextViewController *ctrl = [[TextViewController alloc]init];
        ctrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:ctrl animated:YES];
    }
    else if (indexPath.row == 14){
        KVCViewController *ctrl = [[KVCViewController alloc]init];
        ctrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:ctrl animated:YES];
    }
    else if (indexPath.row == 15){
        ImageSelectViewController *ctrl = [[ImageSelectViewController alloc]init];
        [self.navigationController pushViewController:ctrl animated:YES];
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
